// pages/news/news.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    result:'',
    isTrue:0
  },
  click(){
    var result = new String;
      wx.scanCode({
        success: (res) => {
          this.result = res.result;
          //解析id
          this.id = this.result.split('?')[1].split('=')[1];
          this.setData({
            result: this.result
          });
          //这里要跳转页面到id
          wx.navigateTo({
            url: '../page/page?id='+this.id
          });
          //成功提示
          wx.showToast({
            title: '扫描成功',
            icon: 'success',
            duration: 2000
          });
        },
        fail: (res) => {
          //失败提示
          wx.showToast({
            title: '扫描失败,请重试',
            icon: 'none',
            duration: 2000
          });
        },
        complete: (res) => {
          //这里无论成功失败都会执行
        }
      })
  }
})